#pragma comment(lib, "crypt32.lib")

#include <windows.h>
#include <Wincrypt.h>

bool SmallCrypt_Random(void *buf, size_t len)
{
	HCRYPTPROV cryptProv;
	if(!CryptAcquireContext(&cryptProv, NULL, NULL, PROV_RSA_FULL, 0))
	{
		DWORD err = GetLastError();
		return false;
	}
	bool generated = (CryptGenRandom(cryptProv, static_cast<DWORD>(len), static_cast<BYTE*>(buf)) != FALSE);
	CryptReleaseContext(cryptProv, 0);
	return generated;
}

